import request from '@/utils/request'
import { AxiosPromise } from 'axios'

enum Api {
  list = '/station/parking/list',
  delete = '/station/parking/delete',
  batchDelete = '/station/parking/batchDelete',
  add = '/station/parking/add',
  edit = '/station/parking/edit',
  detail = '/station/parking/detail',
  optionSelect = '/station/parking/optionSelect',
}

// 获取列表
export const parkingList = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 获取选项
export const optionSelect = (data): AxiosPromise<any> => {
  return request({
    url: Api.optionSelect,
    method: 'post',
    data,
  })
}

// 删除
export const parkingDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const parkingBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const parkingSave = (data: any) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 详情
export const parkingDetail = (data: any) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}
